# 业务层：实现功能逻辑(注册和登录)
import orm


def login():
    tag = 0
    name = input('请输入你的用户名：')
    pwd = input('请输入你的密码：')
    sql = f"""
        select * from users where username='{name}' and password='{pwd}'
    """
    data = orm.read_data(sql)
    if data != ():
        tag = 1
        return tag


def register():
    tag = 0
    name = input('请输入要注册的用户名：')
    pwd = input('请输入要注册的密码：')
    sql = f"""
        insert into users values(null, '{name}', '{pwd}')
    """
    rows = orm.write_data(sql)
    if rows > 0:
        tag = 1
    return tag


if __name__ == '__main__':
    # print(assert())
    print(register())
